//
//  main.cpp
//  TEst
//
//  Created by Zachary Brody on 12/7/13.
//  Copyright (c) 2013 Zachary Brody. All rights reserved.
//

#include <iostream>
#include <fstream>
#include <vector>
#include <sstream>

using namespace std;

string sectionOfString (int index1, int index2, string origString)
{
    stringstream tempStream;
    for (int i = index1; i < index2 + 1; i++) {
        tempStream << origString[i];
    }
    tempStream >> origString;
    return origString;
}

void swapItems (int index1, int index2, int array[2])
{
    int temp;
    temp = array[index1];
    array[index1] = array[index2];
    array[index2] = temp;
}

void swapItemsInArray (vector<double> *test)
{
    vector<double> test2 = *test;
    double tempDouble = (test2)[0];
    (test2)[0] = (test2)[1];
    (test2)[1] = tempDouble;
    *test = test2;
}

string allButFirstAndLast (string origString)
{
    return sectionOfString(1, (int)origString.length() - 2, origString);
}

string firstLetter (string origString)
{
    return sectionOfString(0, 0, origString);
}

string stringBackwards (string origString)
{
    if (origString.length() == 0) {
        return "";
    }
    else if (origString.length() == 1)
    {
        return (string)(&origString[0]);
    }
    else {
        return ((string)&origString[origString.length() - 1]).append(stringBackwards(allButFirstAndLast(origString))).append(firstLetter(origString));
    }
}

int factorial (int num)
{
    if (num == 1) {
        return 1;
    } else {
        return num * factorial(num - 1);
    }
}

int addnumbersTo (int num)
{
    if (num == 1) {
        return 1;
    }
    else {
        return num + addnumbersTo(num - 1);
    }
}

int fibonacci (int num)
{
    if (num == 1) {
        return 0;
    } else if (num == 2 || num == 3)
    {
        return 1;
    }
    else {
        return fibonacci(num - 1) + fibonacci(num - 2);
    }
}

int main(int argc, const char * argv[])
{
//    vector<double> test = {0,1,2,3};
//    swapItemsInArray(&test);
//    cout << test[0] << test[1];
//    
//    string myString = "1 2";
//    ifstream input;
//    int one = 0;
//    int two = 0;
//    
//    myString >> one >> two;
    
    cout << fibonacci(8);
    return 0;
}

